// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

export const JSON_FILE_PATH = '/Users/leolin/Documents/NightlyConfig.json'
export const PORT = 8001



const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  publicPath: process.env.NODE_ENV === 'production' ? '/pvch5/' : '/',
  // devtool:'cheap-module-source-map',
  history:{type:'hash'},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/',
      component: '../layouts/UserLayout',
      routes: [
        {
          path: '/',
          redirect: '/configViewer',
        },
        {
          name: 'config viewer',
          path: '/configViewer',
          component: './configViewer',
        },
        {
          component: './404',
        },
      ],
    },
    
    
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  devServer:{
    port: PORT || 8001,
    host:`0.0.0.0`,
    https: false,
    before: function(app) {
      var bodyParser = require('body-parser');
      app.use(bodyParser.json());

      app.post('/saveConfig', bodyParser.json());
    }
  }
});

